package com.example.controller;

import com.csq.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;


/**
 * 使用JavaBean传参时，请求方法类型为POST,不能为GET
 */
@RestController
public class UserController {

    private Logger log =  LoggerFactory.getLogger(UserController.class);

    @Value(value = "${server.port}")
    Integer port;

    @RequestMapping(value = "login", method = RequestMethod.POST)
    public String login(@RequestBody User user){
        log.info("port:" + port);
        if("admin".equals(user.getUsername()) && "123".equals(user.getPassword()))
            return "success ," + user.getUsername() + ",port" + port;
        else
            return "fail: " + user.getUsername()+ ",port" + port;

    }
}
